#ifndef	__I2C_H__
#define	__I2C_H__

typedef enum i2c_direction
{ 
	I2C_WRITE,
	I2C_READ
}I2C_Direction;

#define i2cSetSCL(is_hl)  	              I2C_SCL=is_hl
#define i2cSetSDA(is_hl)	              I2C_SDA=is_hl

#define _HIGH                             1
#define _LOW                              0

#define I2C_ACKNOWLEDGE                   _LOW
#define I2C_NON_ACKNOWLEDGE               _HIGH

#define I2C_DEVICE_ADR_WRITE(slave_adr)   (slave_adr & ~1)
#define I2C_DEVICE_ADR_READ(slave_adr)    (slave_adr | 1)
#define I2C_CHECK_PIN_DUMMY   		      10
#define I2C_ACCESS_DUMMY_TIME   		  10

void I2CStart(void);
void I2CWriteData(BYTE value);
BYTE I2CReadData(void);
void I2CStop(void);
void I2Cdelay(void);

void I2CStartH(void);
void I2CWriteDataH(BYTE value);
BYTE I2CReadDataH(void);
void I2CStopH(void);

void I2CStartL(void);
void I2CWriteDataL(BYTE value);
BYTE I2CReadDataL(void);
void I2CStopL(void);

extern	BYTE	xdata * data regTW88;
#define WriteTW88(a, b)		regTW88[(BYTE)(a)] = ((BYTE)(b))
#define	ReadTW88(a)			regTW88[(BYTE)(a)]

BYTE ReadI2C		(BYTE addr, BYTE index);
void WriteI2C		(BYTE addr, BYTE index, BYTE val);

void I2CDeviceInitialize(BYTE *RegSet);

void MDrv_SW_IIC_ReadBytes(BYTE ucSlaveAdr, BYTE *pBuf, BYTE ucBufLen);

#endif	// __I2C_H__
